﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Configuration
Imports System.Drawing
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class DiscussReply
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        hiddenUsername.Value = Context.User.Identity.Name
        hiddenDiscussID.Value = 0
        If Not Request.QueryString("DiscusID") Is Nothing Then
            hiddenDiscussID.Value = CInt(Request.Params("DiscusID"))
        End If

    End Sub

    Protected Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        Dim tusername As String = hiddenUsername.Value
        Dim discusid As Integer = CInt(hiddenDiscussID.Value)
        If txtMessage.Text <> "" Then
            Dim dbdate As DateTime
            Dim dbtime As TimeSpan
            dbdate = Now.Date
            dbtime = Now.TimeOfDay
            Dim con As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("fishconn").ConnectionString)
            con.Open()
            Dim cmd As New OleDbCommand("insert into tblDiscusThread (DissusionID, Username, Message, MessDate, MessTime) values(@DiscusID, @Username,@Message, @MessageDate, @MessageTime)", con)
            cmd.Parameters.AddWithValue("@DiscusID", discusid)
            cmd.Parameters.AddWithValue("@Username", tusername)
            cmd.Parameters.AddWithValue("@Message", txtMessage.Text)
            cmd.Parameters.AddWithValue("@MessageDate", dbdate)
            cmd.Parameters.AddWithValue("@MessageTim", dbtime)
            cmd.ExecuteNonQuery()
            con.Close()
            Response.Redirect("~/discussreply.aspx?DiscusID=" + CStr(discusid))
        End If
    End Sub

    Protected Sub btnDiscuss_Click(sender As Object, e As EventArgs) Handles btnDiscuss.Click
        Me.ModalPopupExtender1.Show()
    End Sub

End Class